package blue.mqtt4j.internal.client.impl;

import blue.mqtt4j.client.MqttOptions;
import blue.mqtt4j.client.MqttQoS;
import blue.mqtt4j.core.util.AssertUtil;

/**
 * @author Jin Zheng
 * @since 2020-10-02
 */
public class DefaultMqttOptions implements MqttOptions
{
	private String username;
	private String password;
	private String clientId;
	private int maxThreads = 100;
	private boolean cleanSession = false;
	private int timeoutMillis = 5000;
	private int keepAliveSecs = 60;
	private String willTopic;
	private MqttQoS willQoS;
	private byte[] willMessage;
	private boolean willRetain;

	public DefaultMqttOptions()
	{
	}

	@Override
	public String username()
	{
		return username;
	}

	@Override
	public void setAuthorization(String username, String password)
	{
		this.username = username;
		this.password = password;
	}

	@Override
	public String password()
	{
		return password;
	}

	@Override
	public String clientId()
	{
		return clientId;
	}

	@Override
	public void setClientId(String clientId)
	{
		this.clientId = clientId;
	}

	@Override
	public int maxThreads()
	{
		return maxThreads;
	}

	@Override
	public void setMaxThreads(int maxThreads)
	{
		this.maxThreads = maxThreads;
	}

	@Override
	public int timeoutMillis()
	{
		return timeoutMillis;
	}

	@Override
	public void setTimeoutMillis(int timeoutMillis)
	{
		this.timeoutMillis = timeoutMillis;
	}

	@Override
	public int keepAliveSecs()
	{
		return keepAliveSecs;
	}

	@Override
	public void setKeepAliveSecs(int keepAliveSecs)
	{
		this.keepAliveSecs = keepAliveSecs;
	}

	@Override
	public String willTopic()
	{
		return willTopic;
	}

	@Override
	public MqttQoS willQoS()
	{
		return willQoS;
	}

	@Override
	public byte[] willMessage()
	{
		return willMessage;
	}

	@Override
	public boolean willRetain()
	{
		return willRetain;
	}

	@Override
	public void setWillMessage(String willTopic, MqttQoS willQoS, byte[] willMessage, boolean willRetain)
	{
		AssertUtil.isEmpty(willTopic, "Will Topic");
		AssertUtil.isNull(willQoS, "Will QoS");
		AssertUtil.isNull(willMessage, "Will Message");
		this.willTopic = willTopic;
		this.willQoS = willQoS;
		this.willMessage = willMessage;
		this.willRetain = willRetain;
	}
}
